W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem [email protected].
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, zapraszamy na serwery Discord. Są one moderowane przez społeczność, ale członkowie zespołu technicznego też są tam aktywni.
Mr Halfnet works in a telecommunication company Bytetel as a designer of network protocols. At present he works on a protocol to send data from one computer to another by means of a new generation cable. One can send signals of different voltage levels on such a cable, but the voltage may vary only every of a second () of a second during which the voltage must be constant is called an impulse). Data are sent in packets comprising consecutive impulses (i.e. sending one packet takes seconds).
For technical reasons, the voltage must not be constant within each packet, but has to change from time to time. Strictly speaking, one cannot send packets of data containing / consecutive impulses of the same voltage level.
If a protocol enables to send different packets, we say that we can code bits of information in one packet. Mr Halfnet ponders on how many bits of information maximally one is able to send in one second.
Assume the cable enables us to send signals of 2 different voltage levels (), which we denote 0 and 1. If the voltage can vary 20 times per second (), the packets comprise 4 impulses (), and within each packet no 3 consecutive impulses may have the same voltage (), then one cannot send packets: 0000, 0001, 1000, 1111, 1110, 0111. However, one can send packets: 0010, 0011, 0100, 0110, 0101, 1101, 1100, 1011, 1001 and 1010. As one can send 10 different kinds of packets, one can code bits of information in each packet. During a second one can send packets, that is bits of information.
Write a program which:
In the first line of the standard input there are four integers, separated by single spaces:
Additionally, we assume that is an integer less than or equal to 10.
Your program should write, in the first and only line of the standard output, one integer: the maximal number of bits that may be sent during one second, rounded down to the nearest integer.
For the input data:
2 20 4 3
the correct result is:
16
Task author: Marcin Stefaniak.